<?php
/**
 * Prado Portal.
 *
 * @author Steen Rabol <steen.rabol@gmail.com>
 * @link http://www.pradoportal.dk/
 * @copyright Copyright &copy; 2006,2007,2008,2009,2010 Steen Rabol
 * @license http://www.pradoportal.dk
 * @version $Id: index.php 445 2011-01-05 13:09:34Z steen.rabol $
 *
 */

If(isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'))
{
	$protocol	= "https://";
}
else
{
    $protocol = "http://";
}


$baseUrl = $protocol . $_SERVER["SERVER_NAME"] . str_replace("index.php","", $_SERVER["PHP_SELF"]);

$conflen	= strlen('SCRIPT');
$B			= substr(__FILE__,0,strrpos(__FILE__,'/'));
$A			= substr($_SERVER['DOCUMENT_ROOT'], strrpos($_SERVER['DOCUMENT_ROOT'], $_SERVER['PHP_SELF']));
$C			= substr($B,strlen($A));
$posconf	= strlen($C)-$conflen-1;
$D			= substr($C,1,$posconf);
$host		= $protocol . $_SERVER['SERVER_NAME'].'/'.$D;
$baseUrl = $host;




$relUrl			= str_replace("index.php","", $_SERVER["PHP_SELF"]);
$basePath	    = dirname(__FILE__);
$frameworkPath	= $basePath . '/prado/framework/';
$assetsPath	    = $basePath . '/assets';
$runtimePath	= $basePath . '/protected/runtime';
$dataPath		= $basePath . '/protected/Data';
$imagePath		= $basePath . '/images/userimages';
$storagePath	= $basePath . '/storage';
$s_imagepath	= $storagePath . '/images';
$s_mediepath	= $storagePath . '/media';
$s_filepath		= $storagePath . '/file';
$s_imagepath_t	= $s_imagepath . '/_thumbs';


// is the framework installed ??
if(!file_exists($frameworkPath . 'PradoBase.php'))
{
    die('PRADO framework not correctly installed');
}
require_once($basePath .'/protected/Common/PortalBM.php');

// check path and write permission permissions
foreach(array($assetsPath, $runtimePath, $dataPath, $imagePath, $storagePath, $s_imagepath,$s_imagepath_t) as $path)
{
	if(!file_exists($path))
	{
		if(!mkdir($path))
		{
			die("Please make sure that the directory '{$path}' is writeable by the web server process {$message}");
		}
	}
	else if(!is_writable($path))
	{
		die("Please make sure that the directory '{$path}' is writeable by the web server process{$message}");
	}
}

// Browser detection.
require_once($basePath . '/protected/Common/PortalBrowser.php');


// Create our own Prado class
require_once($basePath . '/protected/Common/PortalPrado.php');
require_once($basePath . '/protected/Common/PortalUtil.php');
require_once($basePath . '/protected/Common/PortalApplication.php');

$application	= new PortalApplication();
$application->setPortalBasePath($basePath);
$application->setPortalBaseUrl($baseUrl);
$application->setPortalRelUrl($relUrl);
$application->run();
?>